ccR.GUI = {
	Update =
	function()
		ccR.GUI.Rotation.Update()
		ccR.GUI.Racials.Update()
	end,
	Rotation = {
		Scan =
		function()
			ccR.table_empty(DDM_List) 
			ccR.table_empty(ccR.GUI.Saved.Rotation)
			for k, v in ipairs(ccR.Rotations) do
				if v[1] == (GetSpecialization() or "LowLevel") then
					DDM_List[#DDM_List+1]= v[2]
					ccR.GUI.Saved.Rotation[#ccR.GUI.Saved.Rotation+1]= v[3]
				end
			end
		end,
		Save =
		function()
			ccR.Var("Rotation", UIDropDownMenu_GetText(DDM))
			ccR.PrintToChat("Saved Rotation: " .. ccR.Var("Rotation") .. "()")
		end,
		Update = function()
			ccR.GUI.Rotation.Scan()
			if ccR.Var("Rotation") ~= nil then
				UIDropDownMenu_SetText(DDM, ccR.Var("Rotation"))
				for k,v in ipairs(ccR.Rotations) do
					if v[2] == ccR.Var("Rotation") then
						fsDescription:SetText(v[3])
					end
				end
			end
		end,
	},
	Racials = {
		Update =
		function()
			for k, v in ipairs(ccR.GUI.Saved.Checkboxs) do
				ccR.GUI.Checkbox(v[1], v[2], v[3])			
			end
			for k, v in ipairs(ccR.GUI.Saved.CheckEditSave) do
				ccR.GUI.CheckEditSave(v[1], v[2], v[3], v[4])			
			end		
		end,
	},
	Saved = {
		Rotation = { --[[ Rotation description are stored here ]]},
		Frames = { --[[ Created frames are stored here ]] },
		Frame_Buttons = { --[[ Buttons created inside frames stored here ]]	},
		Buttons = {	--[[ Created buttons are stored here ]]	},
		Class_Buttons = { },
		Checkboxs = { --[[ Created Checkboxs are stored here]] },
		CheckEditSave = { --[[ Created CheckEditSave are stored here ]]},
		Editboxs = { },
	},
	Settings = {
		Button = { Height = 20, Width = 70,	},
		Main = { Height = 260, Width = 325, },
		Frame = { Height = 260, Width = 250, },
		ScrollFrame = { Height = 240, Width = 250 },
		Frame_Button = { Height = 20, Width = 70, },
		Checkbox = { Height = 20, Width = 20, FontHeight=13 },
	},
	Click = {
		Left = function() ccR.GUI.Toggle() end,
		Middle = function() ccR.Sys.PrintToChat("Middle Clicked") end,
		Right = 
		function() 
			if ccR_Features ~= nil then
				if ccR_Features:IsVisible() then
					ccR_Features:Hide()
				else
					ccR_Features:Show()
				end
			end
		end,
	},
	Create = {
		Button = 
		function(name, text, left, top, height, width, parent, script)
			height = height or ccR.GUI.Settings.Button.Height
			width = width or ccR.GUI.Settings.Button.Width
			if parent == nil then parent = "ccR_GUI" else parent = "ccR_GUI_Frame_" .. parent end
			
			self = CreateFrame("Button", parent .. "_" .. name, _G[parent])
			self:SetPoint("TOPLEFT", left, top)
			self:SetHeight(height)
			self:SetWidth(width)
			--self:SetText(text)
			self:SetNormalFontObject("GameFontNormal")
			self:SetScript("OnClick", script)

			local btnFontString 
			btnFontString = self:CreateFontString(self:GetName() .. "_Font", "OVERLAY")
			btnFontString:SetFont("Fonts\\ARIALN.TTF", 12, "THICKOUTLINE")
			btnFontString:SetText(text)
			btnFontString:SetPoint("CENTER", self, "CENTER", 0, 0)
			btnFontString:SetWidth(width)
			btnFontString:SetHeight(height)

			local btnFontStringHighlighht 
			btnFontStringHighlighht = self:CreateFontString(self:GetName() .. "_FontHighlight", "HIGHLIGHT")
			btnFontStringHighlighht:SetFont("Fonts\\ARIALN.TTF", 12, "THICKOUTLINE")
			btnFontStringHighlighht:SetText(text)
			btnFontStringHighlighht:SetPoint("CENTER", self, "CENTER", 0, 0)
			btnFontStringHighlighht:SetWidth(width)
			btnFontStringHighlighht:SetHeight(height)

			local R, G, B
			R = 0 G = 0.8 B = 0

			local btnBorder = self:CreateTexture()
			btnBorder:SetTexture(R, G, B, 1)
			btnBorder:SetVertexColor(R, G, B, 1)
			btnBorder:SetDrawLayer("BACKGROUND", 0)
			btnBorder:SetAllPoints()

			local ntex = self:CreateTexture()
			ntex:SetTexture(0.0, 0.0, 0.0, 1)
			ntex:SetWidth(self:GetWidth()-5)
			ntex:SetHeight(self:GetHeight()-5)
			ntex:SetPoint("CENTER", self, "CENTER", 0, 0)
			ntex:SetBlendMode("DISABLE")
			self:SetNormalTexture(ntex)
			
			local htex = self:CreateTexture()
			htex:SetTexture(R, G, B, 1)
			htex:SetVertexColor(R, G, B, 1)
			htex:SetWidth(self:GetWidth()-5)
			htex:SetHeight(self:GetHeight()-5)
			htex:SetPoint("CENTER", self, "CENTER", 0, 0)
			self:SetHighlightTexture(htex)
			
			local ptex = self:CreateTexture()
			ptex:SetTexture(R, G, B, 1)
			ptex:SetVertexColor(R, G, B, 1)
			ptex:SetWidth(65)
			ptex:SetHeight(15)
			ptex:SetPoint("CENTER", self, "CENTER", 0, 0)
			self:SetPushedTexture(ptex)
		end,
		Frame_Button = 
		function(name, text, left, top, height, width, parent, script)
			height = height or ccR.GUI.Settings.Frame_Button.Height
			width = width or ccR.GUI.Settings.Frame_Button.Width
			parent = parent or "ccR_GUI"

			ccR.GUI.Saved.Frame_Buttons[#ccR.GUI.Saved.Frame_Buttons+1] = parent .. "_" .. name

			self = CreateFrame("Button", parent .. "_" .. name, _G[parent])
			self:SetPoint("TOPLEFT", left, top)
			self:SetHeight(height)
			self:SetWidth(width)
			--self:SetText(text)
			self:SetNormalFontObject("GameFontNormal")
			if script == nil then
				self:SetScript("OnClick", function() ccR.GUI.Frames.Hide(); ccR.GUI.Frames.Show(name); end)
			else
				self:SetScript("OnClick", script)
			end
			local R, G, B
			R = 0 G = 0.8 B = 0

			local btnFontString 
			btnFontString = self:CreateFontString(self:GetName() .. "_Font", "OVERLAY")
			btnFontString:SetFont("Fonts\\ARIALN.TTF", 12, "THICKOUTLINE")
			btnFontString:SetText(text)
			btnFontString:SetPoint("CENTER", self, "CENTER", 0, 0)
			btnFontString:SetWidth(width)
			btnFontString:SetHeight(height)

			local btnFontStringHighlighht 
			btnFontStringHighlighht = self:CreateFontString(self:GetName() .. "_FontHighlight", "HIGHLIGHT")
			btnFontStringHighlighht:SetFont("Fonts\\ARIALN.TTF", 12, "THICKOUTLINE")
			btnFontStringHighlighht:SetText(text)
			btnFontStringHighlighht:SetPoint("CENTER", self, "CENTER", 0, 0)
			btnFontStringHighlighht:SetWidth(width)
			btnFontStringHighlighht:SetHeight(height)

			btnBorder = self:CreateTexture()
			btnBorder:SetTexture(0, 0.8, 0, 1)
			btnBorder:SetVertexColor(0, 0.8, 0, 1)
			btnBorder:SetDrawLayer("BACKGROUND", 0)
			btnBorder:SetAllPoints()

			ntex = self:CreateTexture()
			ntex:SetTexture(0.0, 0.0, 0.0, 1)
			ntex:SetWidth(self:GetWidth()-5)
			ntex:SetHeight(self:GetHeight()-5)
			ntex:SetPoint("CENTER", self, "CENTER", 0, 0)
			ntex:SetBlendMode("DISABLE")
			self:SetNormalTexture(ntex)
			
			htex = self:CreateTexture()
			htex:SetTexture(R, G, B, 1)
			htex:SetVertexColor(R, G, B, 1)
			htex:SetWidth(self:GetWidth()-5)
			htex:SetHeight(self:GetHeight()-5)
			htex:SetPoint("CENTER", self, "CENTER", 0, 0)
			self:SetHighlightTexture(htex)
			
			ptex = self:CreateTexture()
			ptex:SetTexture(R, G, B, 1)
			ptex:SetVertexColor(R, G, B, 1)
			ptex:SetWidth(65)
			ptex:SetHeight(15)
			ptex:SetPoint("CENTER", self, "CENTER", 0, 0)
			self:SetPushedTexture(ptex)
		end,
		Class_Button = 
		function(name, text, left, top, height, width, parent)
			height = height or ccR.GUI.Settings.Frame_Button.Height
			width = width or ccR.GUI.Settings.Frame_Button.Width
			parent = parent or "ccR_GUI"

			ccR.GUI.Saved.Class_Buttons[#ccR.GUI.Saved.Class_Buttons+1] = parent .. "_" .. name

			local R, G, B
			local class = select(2, UnitClass("player"))
			if class == "DEATHKNIGHT" then R = 0.77 G = 0.12 B = 0.23 
			elseif class == "DRUID" then R = 1 G = 0.49 B = 0.04
			elseif class == "HUNTER" then R = 0.67 G = 0.83 B = 0.45
			elseif class == "MAGE" then R = 0.41 G = 0.80 B = 0.94
			elseif class == "MONK" then R = 0.33 G = 0.54 B = 0.52
			elseif class == "PALADIN" then R = 0.96 G = 0.55 B = 0.73
			elseif class == "PRIEST" then R = 0.99 G = 0.99 B = 0.99
			elseif class == "ROGUE" then R = 1 G = 0.96 B = 0.41
			elseif class == "SHAMAN" then R = 0 G = 0.44 B = 0.87
			elseif class == "WARLOCK" then R = 0.58 G = 0.51 B = 0.79
			elseif class == "WARRIOR" then R = 0.78 G = 0.61 B = 0.43
			end
			self = CreateFrame("Button", parent .. "_" .. name, _G[parent])
			self:SetPoint("TOPLEFT", left, top)
			self:SetHeight(height)
			self:SetWidth(width)
			--self:SetText(text)
			self:SetNormalFontObject("GameFontNormal")
			self:SetScript("OnClick", function() ccR.GUI.Frames.Hide(); ccR.GUI.Frames.Show(name); end)
			self:Hide()

			local btnFontString 
			btnFontString = self:CreateFontString(self:GetName() .. "_Font", "OVERLAY")
			btnFontString:SetFont("Fonts\\ARIALN.TTF", 12, "THICKOUTLINE")
			btnFontString:SetText(text)
			btnFontString:SetPoint("CENTER", self, "CENTER", 0, 0)
			btnFontString:SetWidth(width)
			btnFontString:SetHeight(height)

			local btnFontStringHighlighht 
			btnFontStringHighlighht = self:CreateFontString(self:GetName() .. "_FontHighlight", "HIGHLIGHT")
			btnFontStringHighlighht:SetFont("Fonts\\ARIALN.TTF", 12, "THICKOUTLINE")
			btnFontStringHighlighht:SetText(text)
			btnFontStringHighlighht:SetPoint("CENTER", self, "CENTER", 0, 0)
			btnFontStringHighlighht:SetWidth(width)
			btnFontStringHighlighht:SetHeight(height)			

			local btnBorder = self:CreateTexture()
			btnBorder:SetTexture(R, G, B, 1)
			btnBorder:SetVertexColor(R, G, B, 1)
			btnBorder:SetAllPoints()
			btnBorder:SetPoint("TOPLEFT", self, "TOPLEFT", 0, 0)
			btnBorder:SetDrawLayer("BACKGROUND", 0)

			local ntex = self:CreateTexture()
			ntex:SetTexture(0, 0, 0, 1)
			ntex:SetVertexColor(0,0,0,1)
			ntex:SetHeight(self:GetHeight()-5)
			ntex:SetWidth(self:GetWidth()-5)
			ntex:SetPoint("CENTER", self, "CENTER", 0, 0)
			ntex:SetBlendMode("DISABLE")
			self:SetNormalTexture(ntex)
			
			local htex = self:CreateTexture()
			htex:SetTexture(R, G, B, 1)
			htex:SetVertexColor(R, G, B, 1)
			htex:SetWidth(self:GetWidth()-5)
			htex:SetHeight(self:GetHeight()-5)
			htex:SetPoint("CENTER", self, "CENTER", 0, 0)
			htex:SetBlendMode("DISABLE")
			self:SetHighlightTexture(htex)
			
			local ptex = self:CreateTexture()
			ptex:SetTexture(R, G, B, 1)
			ptex:SetVertexColor(R, G, B, 1)
			ptex:SetWidth(65)
			ptex:SetHeight(15)
			ptex:SetPoint("CENTER", self, "CENTER", 0, 0)
			ptex:SetBlendMode("BLEND")
			self:SetPushedTexture(ptex)
		end,
		Frame =
		function(name)
			local self = "ccR_GUI_Frame_" .. name
			self = CreateFrame("ScrollFrame", "ccR_GUI_Frame_" .. name, ccR_GUI)
			ccR.GUI.Saved.Frames[#ccR.GUI.Saved.Frames+1] = self:GetName()
			self:SetBackdrop(backdrop)
			self:SetHeight(ccR.GUI.Settings.Frame.Height)
			self:SetWidth(ccR.GUI.Settings.Frame.Width)
			self:SetPoint("TOPLEFT", 80, -10)
			self:SetFrameStrata("HIGH")
			self:SetMovable(true)
			self:SetScript("OnMouseUp", function() ccR_GUI:StopMovingOrSizing() end)
			self:SetScript("OnMouseDown", function() ccR_GUI:StartMoving() end)
			self:Hide()
		end,
		ScrollFrame =
		function(name, height)
			if height == nil then height = ccR.GUI.Settings.ScrollFrame.Height end
			local self = "ccR_GUI_Frame_" .. name
			local frScrollFrame = "ccR_GUI_Frame_" .. name .. "_ScrollFrame"
			local frScrollBar = "ccR_GUI_Frame_" .. name .. "_Scrollbar"
			local frContent = "ccR_GUI_Frame_" .. name

			ccR.GUI.Saved.Frames[#ccR.GUI.Saved.Frames+1] = self
			--parent frame 
			local frame = CreateFrame("Frame", "ccR_GUI_Frame_" .. name .. "_Parent", ccR_GUI) 
			frame:SetHeight(ccR.GUI.Settings.Frame.Height)
			frame:SetWidth(ccR.GUI.Settings.Frame.Width) 
			frame:SetPoint("TOPLEFT", 80, -10)
			frame:SetBackdrop(backdrop)

			--scrollframe 
			local scrollframe = CreateFrame("ScrollFrame", frScrollFrame, frame) 
			scrollframe:SetPoint("TOPLEFT", 0, 0) 
			scrollframe:SetPoint("BOTTOMRIGHT", -10, 10) 

			frame.scrollframe = scrollframe 

			--scrollbar 
			local scrollbar = CreateFrame("Slider", "ccR_GUI_Frame_" .. name .. "_Scrollbar", scrollframe, "UIPanelScrollBarTemplate") 
			scrollbar:SetPoint("TOPLEFT", frame, "TOPRIGHT", -5, -10) 
			scrollbar:SetPoint("BOTTOMLEFT", frame, "BOTTOMRIGHT", -5, 25) 
			scrollbar:SetMinMaxValues(1, height/2) 
			scrollbar:SetValueStep(5) 
			scrollbar.scrollStep = 1
			scrollbar:SetValue(0) 
			scrollbar:SetWidth(16) 
			scrollbar:SetScript("OnValueChanged", 
			function (self, value) self:GetParent():SetVerticalScroll(value) end) 
			local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND") 
			scrollbg:SetAllPoints(scrollbar) 
			scrollbg:SetTexture(0, 0, 0, 0.4) 
			frame.scrollbar = scrollbar 

			--content frame 
			local content = CreateFrame("Frame", "ccR_GUI_Frame_" .. name, scrollframe) 
			content:SetHeight(height)
			content:SetWidth(ccR.GUI.Settings.ScrollFrame.Width) 
			content:SetScript("OnShow", function(self) if height > 240 then _G[frScrollBar]:Show() end end)
			content:SetScript("OnHide", function(self) _G[frScrollBar]:Hide() end)
			content:SetScript('OnMouseWheel', 
			function(this, delta)
				if delta == 1 then
					if scrollframe:GetVerticalScroll() > 0 then
						scrollframe:SetVerticalScroll(scrollframe:GetVerticalScroll() - 5)
					end
				elseif delta == -1 then
					local minValue, maxValue = scrollbar:GetMinMaxValues()
					if scrollframe:GetVerticalScroll() < maxValue then
						scrollframe:SetVerticalScroll(scrollframe:GetVerticalScroll() + 5)
					end
				end
				scrollbar:SetValue(scrollframe:GetVerticalScroll())
			end)
			scrollframe.content = content 
			scrollframe:SetScrollChild(content)

			content:Hide()
		end,
		Checkbox =
		function(name, text, left, top, height, width, parent, save, linked, untick)
			height = height or ccR.GUI.Settings.Checkbox.Height
			width = width or ccR.GUI.Settings.Checkbox.Width
			fontheight = fontheight or ccR.GUI.Settings.Checkbox.FontHeight
			parent = "ccR_GUI_Frame_" .. parent
			local self = name
			-- New
			local R, G, B
			R = 0 G = 0.8 B = 0
			local class = select(2, UnitClass("player"))
			if class == "DEATHKNIGHT" then R = 0.77 G = 0.12 B = 0.23 
			elseif class == "DRUID" then R = 1 G = 0.49 B = 0.04
			elseif class == "HUNTER" then R = 0.67 G = 0.83 B = 0.45
			elseif class == "MAGE" then R = 0.41 G = 0.80 B = 0.94
			elseif class == "MONK" then R = 0.33 G = 0.54 B = 0.52
			elseif class == "PALADIN" then R = 0.96 G = 0.55 B = 0.73
			elseif class == "PRIEST" then R = 0.99 G = 0.99 B = 0.99
			elseif class == "ROGUE" then R = 1 G = 0.96 B = 0.41
			elseif class == "SHAMAN" then R = 0 G = 0.44 B = 0.87
			elseif class == "WARLOCK" then R = 0.58 G = 0.51 B = 0.79
			elseif class == "WARRIOR" then R = 0.78 G = 0.61 B = 0.43
			end

			self = CreateFrame("CheckButton", parent .. "_" .. name, _G[parent])
			self:SetPoint("TOPLEFT", left, top)
			self:SetWidth(15)
			self:SetHeight(15)
			self:SetNormalFontObject("GameFontNormal")		
			self:SetScript("OnShow", 
			function()
				if linked ~= nil then
					if self:GetChecked(true) then
						for x = 1, # linked do _G[parent .. "_" .. linked[x]]:Enable() _G[parent .. "_" .. linked[x] .. "_Font"]:SetAlpha(1) end
					else
						for x = 1, # linked do _G[parent .. "_" .. linked[x]]:Disable() _G[parent .. "_" .. linked[x] .. "_Font"]:SetAlpha(0.5) end
					end
				end
				if self:GetChecked(true) then
					_G[self:GetName() .. "_Checked"]:SetTexture(R, G, B, 1) 
					_G[self:GetName() .. "_Checked"]:SetVertexColor(R, G, B, 1) 
				else
					_G[self:GetName() .. "_Checked"]:SetTexture(0, 0, 0, 1) 
					_G[self:GetName() .. "_Checked"]:SetVertexColor(0, 0, 0, 1) 
				end
				--[[if untick ~= nil then
					if self:GetChecked(true) then
						for x = 1, # untick do 
							_G[parent .. "_" .. untick[x] ]:SetChecked(false)
							_G[parent .. "_" .. untick[x] .. "_Checked"]:SetTexture(0, 0, 0, 1) 
							_G[parent .. "_" .. untick[x] .. "_Checked"]:SetVertexColor(0, 0, 0, 1) 
						end
					end
				end]]
			end)
			if save ~= nil then
				ccR.GUI.Saved.Checkboxs[#ccR.GUI.Saved.Checkboxs+1]= { name, parent, save } 
				self:SetScript("OnClick", 
				function() 
					ccR.Var(save, self:GetChecked()) 
					if linked ~= nil then
						if self:GetChecked(true) then
							for x = 1, # linked do _G[parent .. "_" .. linked[x]]:Enable() _G[parent .. "_" .. linked[x] .. "_Font"]:SetAlpha(1) end
						else
							for x = 1, # linked do _G[parent .. "_" .. linked[x]]:Disable() _G[parent .. "_" .. linked[x] .. "_Font"]:SetAlpha(0.5) end
						end
					end
					if self:GetChecked(true) then
						_G[self:GetName() .. "_Checked"]:SetTexture(R, G, B, 1) 
						_G[self:GetName() .. "_Checked"]:SetVertexColor(R, G, B, 1) 
					else
						_G[self:GetName() .. "_Checked"]:SetTexture(0, 0, 0, 1) 
						_G[self:GetName() .. "_Checked"]:SetVertexColor(0, 0, 0, 1) 
					end
					if untick ~= nil then
						if self:GetChecked(true) then
							for x = 1, # untick do 
								if _G[parent .. "_" .. untick[x]]:GetChecked(true) then
									_G[parent .. "_" .. untick[x]]:Click("LeftButton", true)
								end
							end
						end
					end
				end)
			end

			local chkFontString 
			chkFontString = self:CreateFontString(self:GetName() .. "_Font", "OVERLAY")
			chkFontString:SetFont("Fonts\\ARIALN.TTF", 12, "THICKOUTLINE")
			chkFontString:SetPoint("LEFT", self, "LEFT", 18, 0)
			chkFontString:SetWidth(300)
			chkFontString:SetHeight(height)
			chkFontString:SetText(text)
			chkFontString:SetJustifyV("LEFT")
			chkFontString:SetJustifyH("LEFT")

			local chkFontStringHighlighht 
			chkFontStringHighlighht = self:CreateFontString(self:GetName() .. "_FontHighlight", "HIGHLIGHT")
			chkFontStringHighlighht:SetFont("Fonts\\ARIALN.TTF", 12, "THICKOUTLINE")
			chkFontStringHighlighht:SetPoint("LEFT", self, "LEFT", 18, 0)
			chkFontStringHighlighht:SetWidth(300)
			chkFontStringHighlighht:SetHeight(height)
			chkFontStringHighlighht:SetText(text)
			chkFontStringHighlighht:SetJustifyV("LEFT")
			chkFontStringHighlighht:SetJustifyH("LEFT")

			chkBorder = self:CreateTexture(self:GetName() .. "_Background", "BACKGROUND")
			chkBorder:SetTexture(0, 0.5, 0, 1)
			chkBorder:SetVertexColor(0, 0.5, 0, 1)
			chkBorder:SetDrawLayer("BACKGROUND", 0)
			chkBorder:SetAllPoints()

			chkntex = self:CreateTexture(self:GetName() .. "_Checked", "HIGHLIGHT")
			--[[if self:GetChecked(true) then
				chkntex:SetTexture(R, G, B, 1)
				chkntex:SetVertexColor(R, G, B, 1)
			else
				chkntex:SetTexture(0, 0, 0, 1) 
				chkntex:SetVertexColor(0, 0, 0, 1)
			end]]

			chkntex:SetWidth(self:GetWidth()-6)
			chkntex:SetHeight(self:GetHeight()-6)
			chkntex:SetPoint("CENTER", self, "CENTER", 0, 0)
			chkntex:SetBlendMode("DISABLE")
			self:SetNormalTexture(chkntex)
			
			chkhtex = self:CreateTexture(self:GetName() .. "_Highlight", "HIGHLIGHT")
			chkhtex:SetTexture(R, G, B, 1)
			chkhtex:SetVertexColor(R, G, B, 1)
			chkhtex:SetWidth(self:GetWidth()-6)
			chkhtex:SetHeight(self:GetHeight()-6)
			chkhtex:SetPoint("CENTER", self, "CENTER", 0, 0)
			self:SetHighlightTexture(chkhtex)
			
			chkptex = self:CreateTexture()
			chkptex:SetTexture(R, G, B, 1)
			chkptex:SetVertexColor(R, G, B, 1)
			chkptex:SetWidth(self:GetWidth()-6)
			chkptex:SetHeight(self:GetHeight()-6)
			chkptex:SetPoint("CENTER", self, "CENTER", 0, 0)
			self:SetPushedTexture(chkptex)
		end,
		FontString =
		function(name, text, left, top, height, width, fontsize, parent, justify)
			justify = justify or "LEFT"
			local self = name
			self = _G["ccR_GUI_Frame_" .. parent]:CreateFontString(self, "HIGH", "GameFontNormal", _G["ccR_GUI_Frame_" .. parent]);
			self:SetText(text);
			self:SetFont("Fonts\\ARIALN.TTF", fontsize, "OUTLINE");
			self:SetPoint("TOPLEFT", left, top);		
			self:SetSize(height, width)
			self:SetJustifyH(justify)
			self:SetJustifyV("TOP")
		end,
		MissingFontString =
		function(name, text, left, top, height, width, fontsize, parent)
			local self = name
			self = _G["ccR_GUI_Frame_" .. parent]:CreateFontString(self, "HIGH", "GameFontNormal", _G["ccR_GUI_Frame_" .. parent]);
			self:SetText(text);
			self:SetFont("Fonts\\ARIALN.TTF", fontsize, "OUTLINE");
			self:SetPoint("TOPLEFT", left, top);		
			self:SetSize(height, width)
			self:SetJustifyH("CENTER")
			self:SetJustifyV("CENTER")
		end,
		Editbox =
		function(name, left, top, height, width, parent)
			local self = name
			self = CreateFrame("editbox", "ccR_GUI_Frame_" .. parent .. "_" .. name, _G["ccR_GUI_Frame_" .. parent], "InputBoxTemplate")
			self:SetHeight(height)
			self:SetWidth(width)
			self:SetPoint("TOPLEFT",left,top)
			self:SetNumeric(false)
			self:SetAutoFocus(false)
			ccR.GUI.Saved.Editboxs[#ccR.GUI.Saved.Editboxs+1] = "ccR_GUI_Frame_" .. parent .. "_" .. name
		end,
		Save =
		function(name, left, top, parent, script)
			local self = name
			self = CreateFrame("Button", parent .. "_" .. name, _G["ccR_GUI_Frame_" .. parent], "UIPanelButtonTemplate")
			self:SetText("Save")
			self:SetHeight(25)
			self:SetWidth(40)
			self:SetPoint("TOPLEFT", left, top)
			self:SetScript("OnClick", script)
		end,
		CheckEditSave =
		function(name, text, left, top, height, width, parent, script, save, lock, linked, untick)
			if height == nil then height = ccR.GUI.Settings.Checkbox.Height end
			if width == nil then width = ccR.GUI.Settings.Checkbox.Width end
			if FontHeight == nil then FontHeight = ccR.GUI.Settings.Checkbox.FontHeight end 

			parent = "ccR_GUI_Frame_" .. parent
			local self = "chk" .. name
			local ebself = "eb" .. name
			local sself = "s" .. name
			local R, G, B
			R = 0 G = 0.8 B = 0
			local class = select(2, UnitClass("player"))
			if class == "DEATHKNIGHT" then R = 0.77 G = 0.12 B = 0.23 
			elseif class == "DRUID" then R = 1 G = 0.49 B = 0.04
			elseif class == "HUNTER" then R = 0.67 G = 0.83 B = 0.45
			elseif class == "MAGE" then R = 0.41 G = 0.80 B = 0.94
			elseif class == "MONK" then R = 0.33 G = 0.54 B = 0.52
			elseif class == "PALADIN" then R = 0.96 G = 0.55 B = 0.73
			elseif class == "PRIEST" then R = 0.99 G = 0.99 B = 0.99
			elseif class == "ROGUE" then R = 1 G = 0.96 B = 0.41
			elseif class == "SHAMAN" then R = 0 G = 0.44 B = 0.87
			elseif class == "WARLOCK" then R = 0.58 G = 0.51 B = 0.79
			elseif class == "WARRIOR" then R = 0.78 G = 0.61 B = 0.43
			end

			self = CreateFrame("CheckButton", parent .. "_" .. "chk" .. name, _G[parent])
			self:SetPoint("TOPLEFT", left, top)
			self:SetWidth(15)
			self:SetHeight(15)
			self:SetNormalFontObject("GameFontNormal")
			self:SetScript("OnShow", 
			function()
				if lock ~= nil then self:Disable() end
				if self:GetChecked(true) then
					ebself:Enable()
					ebself:SetAlpha(1)
					sself:Enable()
					sself:SetAlpha(1)
					_G[self:GetName() .. "_Checked"]:SetTexture(R, G, B, 1)
					_G[self:GetName() .. "_Checked"]:SetVertexColor(R, G, B, 1)
				else
					ebself:Disable()
					ebself:SetAlpha(0.5)
					sself:Disable()
					sself:SetAlpha(0.5)
					_G[self:GetName() .. "_Checked"]:SetTexture(0, 0, 0, 1)
					_G[self:GetName() .. "_Checked"]:SetVertexColor(0, 0, 0, 1)
				end
				if linked ~= nil then
					if self:GetChecked(true) then
						for x = 1, # linked do _G[parent .. "_" .. linked[x]]:Enable() _G[parent .. "_" .. linked[x] .. "_Font"]:SetAlpha(1) end
					else
						for x = 1, # linked do _G[parent .. "_" .. linked[x]]:Disable() _G[parent .. "_" .. linked[x] .. "_Font"]:SetAlpha(0.5) end
					end
				end
				if untick ~= nil then
					if self:GetChecked(true) then
						for x = 1, # untick do _G[parent .. "_" .. untick[x]]:SetChecked(false) end
					end
				end
			end)
			self:SetScript("OnClick", 
			function() 
				if name ~= "chkDebug" then ccR.Var(script, self:GetChecked()) end
				if self:GetChecked() then
					if name == "chkDebug" then ccR.GUI.Debug.Start() end
					ebself:Enable()
					ebself:SetAlpha(1)
					sself:Enable()
					sself:SetAlpha(1)
					_G[self:GetName() .. "_Checked"]:SetTexture(R, G, B, 1)
					_G[self:GetName() .. "_Checked"]:SetVertexColor(R, G, B, 1)
				else
					if name == "chkDebug" then ccR.GUI.Debug.Stop() end
					ebself:Disable()
					ebself:SetAlpha(0.5)
					sself:Disable()
					sself:SetAlpha(0.5)
					_G[self:GetName() .. "_Checked"]:SetTexture(0, 0, 0, 1)
					_G[self:GetName() .. "_Checked"]:SetVertexColor(0, 0, 0, 1)
				end
				if linked ~= nil then
					if self:GetChecked(true) then
						for x = 1, # linked do _G[parent .. "_" .. linked[x]]:Enable() _G[parent .. "_" .. linked[x] .. "_Font"]:SetAlpha(1) end
					else
						for x = 1, # linked do _G[parent .. "_" .. linked[x]]:Disable() _G[parent .. "_" .. linked[x] .. "_Font"]:SetAlpha(0.5) end
					end
				end
				if untick ~= nil then
					if self:GetChecked(true) then
						for x = 1, # untick do _G[parent .. "_" .. untick[x]]:SetChecked(false) end
					end
				end
			end)

			local chkFontString 
			chkFontString = self:CreateFontString(self:GetName() .. "_Font", "OVERLAY")
			chkFontString:SetFont("Fonts\\ARIALN.TTF", 12, "THICKOUTLINE")
			chkFontString:SetPoint("LEFT", self, "LEFT", 18, 0)
			chkFontString:SetWidth(300)
			chkFontString:SetHeight(height)
			chkFontString:SetText(text)
			chkFontString:SetJustifyV("LEFT")
			chkFontString:SetJustifyH("LEFT")

			local chkFontStringHighlighht 
			chkFontStringHighlighht = self:CreateFontString(self:GetName() .. "_FontHighlight", "HIGHLIGHT")
			chkFontStringHighlighht:SetFont("Fonts\\ARIALN.TTF", 12, "THICKOUTLINE")
			chkFontStringHighlighht:SetPoint("LEFT", self, "LEFT", 18, 0)
			chkFontStringHighlighht:SetWidth(300)
			chkFontStringHighlighht:SetHeight(height)
			chkFontStringHighlighht:SetText(text)
			chkFontStringHighlighht:SetJustifyV("LEFT")
			chkFontStringHighlighht:SetJustifyH("LEFT")

			chkBorder = self:CreateTexture()
			chkBorder:SetTexture(0, 0.5, 0, 1)
			chkBorder:SetVertexColor(0, 0.5, 0, 1)
			chkBorder:SetDrawLayer("BACKGROUND", 0)
			chkBorder:SetAllPoints()

			chkntex = self:CreateTexture(self:GetName() .. "_Checked")
			--			if self:GetChecked(true) then chkntex:SetTexture(1, 1, 1, 1) else chkntex:SetTexture(0.0, 0.0, 0.0, 1) end
			chkntex:SetWidth(self:GetWidth()-6)
			chkntex:SetHeight(self:GetHeight()-6)
			chkntex:SetPoint("CENTER", self, "CENTER", 0, 0)
			chkntex:SetBlendMode("DISABLE")
			self:SetNormalTexture(chkntex)
			
			chkhtex = self:CreateTexture()
			chkhtex:SetTexture(R, G, B, 1)
			chkhtex:SetVertexColor(R, G, B, 1)
			chkhtex:SetWidth(self:GetWidth()-6)
			chkhtex:SetHeight(self:GetHeight()-6)
			chkhtex:SetPoint("CENTER", self, "CENTER", 0, 0)
			self:SetHighlightTexture(chkhtex)
			
			chkptex = self:CreateTexture()
			chkptex:SetTexture(R, G, B, 1)
			chkptex:SetVertexColor(R, G, B, 1)
			chkptex:SetWidth(self:GetWidth()-6)
			chkptex:SetHeight(self:GetHeight()-6)
			chkptex:SetPoint("CENTER", self, "CENTER", 0, 0)
			self:SetPushedTexture(chkptex)


			--
			-- EDIT BOX
			--

			--[[
			ebself = CreateFrame("editbox", parent .. "_" .. "eb" .. name, _G[parent], "InputBoxTemplate")
			ebself:SetPoint("TOPLEFT", 160, top-5)
			ebself:SetHeight(10)
			ebself:SetWidth(40)
			ebself:SetAutoFocus(false)
			ebself:SetMaxLetters(5)
			ebself:SetScript("OnEnterPressed",
				function() 
					ebself:ClearFocus() 
					ccR.Var(save, tonumber(ebself:GetText())) 
				end)
			]]

			ebself = CreateFrame("editbox", parent .. "_" .. "eb" .. name, _G[parent])
			ebself:SetPoint("TOPLEFT", 155, top)
			ebself:SetHeight(20)
			ebself:SetWidth(40)
			ebself:SetAutoFocus(false)
		--	ebself:SetMaxLetters(5)
			ebself:SetFontObject("GameFontNormal")
			ebself:SetJustifyH("CENTER")
			ebself:SetScript("OnEnterPressed",
				function() 
					ebself:ClearFocus() 
					ccR.Var(save, ebself:GetText())
				end)  
			ebself:SetScript("OnEscapePressed",
				function()
					ebself:ClearFocus()
				end)

			local R, G, B
			R = 0 G = 0.8 B = 0
			local ebFontString 
			ebFontString = ebself:CreateFontString(ebself:GetName() .. "_Font", "OVERLAY")
			ebFontString:SetFont("Fonts\\ARIALN.TTF", 10, "THICKOUTLINE")
			--ebFontString:SetText("Save")
			ebFontString:SetPoint("CENTER", ebself, "CENTER", 0, 0)
			ebFontString:SetHeight(20)
			ebFontString:SetWidth(40)
			ebFontString:SetJustifyH("CENTER")

			local ebFontStringHighlighht 
			ebFontStringHighlighht = ebself:CreateFontString(ebself:GetName() .. "_FontHighlight", "HIGHLIGHT")
			--ebFontStringHighlighht:SetFontObject("Fonts\\ARIALN.TTF", 12, "THICKOUTLINE")
			--ebFontStringHighlighht:SetText("Save")
			ebFontStringHighlighht:SetPoint("CENTER", ebself, "CENTER", 0, 0)
			ebFontStringHighlighht:SetHeight(20)
			ebFontStringHighlighht:SetWidth(40)

			ebBorder = ebself:CreateTexture()
			ebBorder:SetTexture(0, 0.8, 0, 1)
			ebBorder:SetVertexColor(0, 0.8, 0, 1)
			ebBorder:SetDrawLayer("BACKGROUND", 0)
			ebBorder:SetAllPoints()

			ebNtex = ebself:CreateTexture()
			ebNtex:SetTexture(0.0, 0.0, 0.0, 1)
			ebNtex:SetWidth(ebself:GetWidth()-5)
			ebNtex:SetHeight(ebself:GetHeight()-5)
			ebNtex:SetPoint("CENTER", ebself, "CENTER", 0, 0)
			ebNtex:SetBlendMode("DISABLE")
			--ebself:SetTexture(ebNtex)

			--
			-- SAVE BUTTON
			--

			--[[sself = CreateFrame("Button", parent .. "_" .. "s" .. name, _G[parent], "UIPanelButtonTemplate")
			sself:SetText("Save")
			sself:SetHeight(20)
			sself:SetWidth(40)
			sself:SetPoint("TOPLEFT", 200, top )
			if save ~= nil then
				sself:SetScript("OnClick", 
				function() 
					ebself:ClearFocus() 
					ccR.Var(save, tonumber(ebself:GetText()))
					if name == "chkDebug" then
						ccR.GUI.Debug.Stop()
						ccR.GUI.Debug.Start()
					end
				end)
			end]]

			sself = CreateFrame("Button", parent .. "_" .. "s" .. name, _G[parent])
			sself:SetPoint("TOPLEFT", 200, top)
			sself:SetWidth(40)
			sself:SetHeight(20)
			sself:SetNormalFontObject("GameFontNormal")
			if save ~= nil then
				sself:SetScript("OnClick", 
				function() 
					ebself:ClearFocus() 
					ccR.Var(save, ebself:GetText())
				end)
			end
			local R, G, B
			R = 0 G = 0.8 B = 0

			local btnFontString 
			btnFontString = sself:CreateFontString(sself:GetName() .. "_Font", "OVERLAY")
			btnFontString:SetFont("Fonts\\ARIALN.TTF", 12, "THICKOUTLINE")
			btnFontString:SetText("Save")
			btnFontString:SetPoint("CENTER", sself, "CENTER", 0, 0)
			btnFontString:SetWidth(40)
			btnFontString:SetHeight(20)

			local btnFontStringHighlighht 
			btnFontStringHighlighht = sself:CreateFontString(sself:GetName() .. "_FontHighlight", "HIGHLIGHT")
			btnFontStringHighlighht:SetFont("Fonts\\ARIALN.TTF", 12, "THICKOUTLINE")
			btnFontStringHighlighht:SetText("Save")
			btnFontStringHighlighht:SetPoint("CENTER", sself, "CENTER", 0, 0)
			btnFontStringHighlighht:SetWidth(40)
			btnFontStringHighlighht:SetHeight(20)

			btnBorder = sself:CreateTexture()
			btnBorder:SetTexture(0, 0.8, 0, 1)
			btnBorder:SetVertexColor(0, 0.8, 0, 1)
			btnBorder:SetDrawLayer("BACKGROUND", 0)
			btnBorder:SetAllPoints()

			ntex = sself:CreateTexture()
			ntex:SetTexture(0.0, 0.0, 0.0, 1)
			ntex:SetWidth(sself:GetWidth()-5)
			ntex:SetHeight(sself:GetHeight()-5)
			ntex:SetPoint("CENTER", sself, "CENTER", 0, 0)
			ntex:SetBlendMode("DISABLE")
			sself:SetNormalTexture(ntex)
			
			htex = sself:CreateTexture()
			htex:SetTexture(R, G, B, 1)
			htex:SetVertexColor(R, G, B, 1)
			htex:SetWidth(sself:GetWidth()-5)
			htex:SetHeight(sself:GetHeight()-5)
			htex:SetPoint("CENTER", sself, "CENTER", 0, 0)
			sself:SetHighlightTexture(htex)
			
			ptex = sself:CreateTexture()
			ptex:SetTexture(R, G, B, 1)
			ptex:SetVertexColor(R, G, B, 1)
			ptex:SetWidth(sself:GetWidth()-5)
			ptex:SetHeight(sself:GetHeight()-5)
			ptex:SetPoint("CENTER", sself, "CENTER", 0, 0)
			sself:SetPushedTexture(ptex)

			ccR.GUI.Saved.CheckEditSave[#ccR.GUI.Saved.CheckEditSave+1]= { name, parent, script, save } 
		end,
	},
	Frames = {
		Show =
		function(name)
			if name == "Rotation" then ccR.GUI.Rotation.Update() end
			if name == "Char_Talents"
			or name == "Char_Abilities"
			or name == "Char_Features"
			or name == "Char_Setup"
			then
				-- ccR_GUI_Frame_Druid_Restoration_Talents
				local num = nil
				if name == "Char_Talents" then num = 4 end
				if name == "Char_Abilities" then num = 5 end
				if name == "Char_Features" then num = 6 end
				if name == "Char_Setup" then num = 7 end
				for k,v in ipairs(ccR.Rotations) do
					if v[2] == ccR.Var("Rotation")
					and v[num] ~= nil 
					then
						if _G["ccR_GUI_Frame_" .. v[num]] ~= nil then
							_G["ccR_GUI_Frame_" .. v[num]]:Show()
							return
						end
					end
				end
				if _G["ccR_GUI_Frame_" .. name] ~= nil then _G["ccR_GUI_Frame_" .. name]:Show() end
			else
				if _G["ccR_GUI_Frame_" .. name] ~= nil then _G["ccR_GUI_Frame_" .. name]:Show() end
			end
		end,
		Hide = 
		function() 
			for x = 1, # ccR.GUI.Saved.Frames do
				local frame = ccR.GUI.Saved.Frames[x]
				_G[frame]:Hide()
			end
		end,
	},
	Toggle = 
	function() 
		if ccR_GUI ~= nil then
			if ccR_GUI:IsVisible() then
				ccR_GUI:Hide()
			else
				ccR.GUI.Update()
				ccR_GUI:Show()
			end
		end
	end,
	Checkbox =
	function(name, frame, var)
		_G[frame .. "_" .. name]:SetChecked(ccR.Var(var))
	end,
	CheckEditSave =
	function(name, frame, check, input)
		if ccR.Var(check) ~= nil then _G[frame .. "_chk" .. name]:SetChecked(ccR.Var(check)) end
		if ccR.Var(input) ~= nil then _G[frame .. "_eb" .. name]:SetText(ccR.Var(input)) end
	end,
	Switch = {
		To = {
			Addon = function() end,
			Class = function() end,
			Debug = function() end,
		},
	},
	Debug = {
		Start = function() ccR_Timer.Register('ccR_Debug', ccR.GUI.Debug.Update, ccR.Var("Debug_Delay")) end,
		Stop = function() ccR_Timer.Unregister('ccR_Debug') end,
		Update =
		function()
			if not _G["ccR_GUI_Frame_Debug"]:IsVisible() then
				_G["ccR_GUI_Frame_Debug_chkchkDebug"]:SetChecked(false)
				ccR.GUI.Debug.Stop() 
				return 
			end
			_G["ccR_GUI_Frame_Debug_ebPlayerCount8"]:SetText(ccR.Player.Count(8))
			_G["ccR_GUI_Frame_Debug_ebPlayerCount10"]:SetText(ccR.Player.Count(10))
			_G["ccR_GUI_Frame_Debug_ebPlayerCount12"]:SetText(ccR.Player.Count(12))
			_G["ccR_GUI_Frame_Debug_ebPlayerCount16"]:SetText(ccR.Player.Count(16))
			_G["ccR_GUI_Frame_Debug_ebTargetExists"]:SetText(tostring(ccR.Target.Exists()))
			if _G["ccR_GUI_Frame_Debug_ebTargetExists"]:GetText() == "true" then
				_G["ccR_GUI_Frame_Debug_ebTargetIsBoss"]:SetText(tostring(ccR.Target.Is.Boss()))
				_G["ccR_GUI_Frame_Debug_ebTargetDistanceToCenter"]:SetText(string.sub(ccR.Target.Distance("raw"), 1, 9))
				_G["ccR_GUI_Frame_Debug_ebTargetDistanceToCombatReach"]:SetText(string.sub(ccR.Target.Distance(), 1, 9))
				_G["ccR_GUI_Frame_Debug_ebTargetLoS"]:SetText(tostring(ccR.Target.Is.InLineOfSight()))
				_G["ccR_GUI_Frame_Debug_ebTargetCount8"]:SetText(ccR.Target.Count(8))
				_G["ccR_GUI_Frame_Debug_ebTargetCount10"]:SetText(ccR.Target.Count(10))
				_G["ccR_GUI_Frame_Debug_ebTargetCount12"]:SetText(ccR.Target.Count(12))
				_G["ccR_GUI_Frame_Debug_ebTargetCount16"]:SetText(ccR.Target.Count(16))
			else
				_G["ccR_GUI_Frame_Debug_ebTargetIsBoss"]:SetText("-")
				_G["ccR_GUI_Frame_Debug_ebTargetDistanceToCenter"]:SetText("-")
				_G["ccR_GUI_Frame_Debug_ebTargetDistanceToCombatReach"]:SetText("-")
				_G["ccR_GUI_Frame_Debug_ebTargetLoS"]:SetText("-")
				_G["ccR_GUI_Frame_Debug_ebTargetCount8"]:SetText("-")
				_G["ccR_GUI_Frame_Debug_ebTargetCount10"]:SetText("-")
				_G["ccR_GUI_Frame_Debug_ebTargetCount12"]:SetText("-")
				_G["ccR_GUI_Frame_Debug_ebTargetCount16"]:SetText("-")
			end
			_G["ccR_GUI_Frame_Debug_ebEnemies"]:SetText(#ccR_Enemies)
			_G["ccR_GUI_Frame_Debug_ebEnemiesInCombat"]:SetText(#ccR_Enemies_In_Combat)
			_G["ccR_GUI_Frame_Debug_ebEnemiesWithin44"]:SetText(#ccR_Enemies_Within_44)
			_G["ccR_GUI_Frame_Debug_ebEnemiesWithin16"]:SetText(#ccR_Enemies_Within_16)
			_G["ccR_GUI_Frame_Debug_ebEnemiesWithin12"]:SetText(#ccR_Enemies_Within_12)
			_G["ccR_GUI_Frame_Debug_ebEnemiesWithin10"]:SetText(#ccR_Enemies_Within_10)
			_G["ccR_GUI_Frame_Debug_ebEnemiesWithin8"]:SetText(#ccR_Enemies_Within_8)

			_G["ccR_GUI_Frame_Debug_ebFriendly"]:SetText(#ccR_Friendly)
		end,
	}
}
setmetatable(ccR.GUI, ccR)

-- Main GUI
	local self = "ccR_GUI"
	local GUIParent = "ccR_GUI"
	local GUIParentFrame = "ccR_GUI_Frame_"
	local backdrop = {
		bgFile = "Interface\\Tooltips\\CHATBUBBLE-BACKGROUND",
		edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
		edgeSize = 32,
		tile = true,
		tileSize = 32,
		insets = {
			top = 4,
			right = 4,
			left = 4,
			bottom = 4,
		}
	}

	self = CreateFrame("Frame", self)
	self:SetPoint("TOPLEFT", left, top)
	self:SetHeight(ccR.GUI.Settings.Main.Height)
	self:SetWidth(ccR.GUI.Settings.Main.Width)
	self:SetPoint("CENTER", -200, 100)
	self:SetFrameStrata("HIGH")
	self:SetMovable(true)
	self:SetScript("OnMouseUp", function() ccR_GUI:StopMovingOrSizing() end)
	self:SetScript("OnMouseDown", function() ccR_GUI:StartMoving() end)

	local R, G, B
	R = 0 G = 0.8 B = 0

	local btnBorder = self:CreateTexture()
	btnBorder:SetTexture(R, G, B, 0.5)
	btnBorder:SetVertexColor(R, G, B, 0.5)
	btnBorder:SetAllPoints()

	local ntex = self:CreateTexture()
	ntex:SetTexture(0.0, 0.0, 0.0, 0.5)
	ntex:SetWidth(self:GetWidth()-5)
	ntex:SetHeight(self:GetHeight()-5)
	ntex:SetPoint("CENTER", self, "CENTER", 0, 0)
	ntex:SetBlendMode("BLEND")
-- Title
	self = GUIParent .. "_Title"
	self = CreateFrame("MessageFrame", self, _G[GUIParent])
	self:SetBackdrop({edgeFile = nil, edgeSize = 32, tile = true, tileSize = 32, insets = { left = 0, right = 0, top = 0, bottom = 0 }})
	self:SetWidth(200)
	self:SetHeight(25)
	self:SetPoint("TOPLEFT", 10, 15)
	self:SetBackdropColor(0,0,0,0.7)
	self:SetFontObject(SystemFont_Shadow_Large_Outline)
	self:SetJustifyH("LEFT")
	self:SetJustifyV("TOP")
	self:SetFading(false)
	-- ccR_GUI_Title:AddMessage("_ccR Settings", 0, 0.75, 0.75, 1)
	self:AddMessage("_ccR Settings", 0, 0.75, 0.75, 1)
	self:RegisterForDrag("LeftButton")
	self:SetScript("OnMouseUp", function() _G[GUIParent]:StopMovingOrSizing() end)
	self:SetScript("OnMouseDown", function() _G[GUIParent]:StartMoving() end)
	self:SetScript("OnDragStart", function() _G[GUIParent]:StartMoving() end)
	self:SetScript("OnDragStop", function() _G[GUIParent]:StopMovingOrSizing() end)
-- 2nd Row
	ccR.GUI.Create.Class_Button("Rotation", "Rotation", 8, -10, 20, 70)
	ccR.GUI.Create.Class_Button("Char_Talents", "Talents", 8, -25, 20, 70)
	ccR.GUI.Create.Class_Button("Char_Abilities", "Abilities", 8, -40, 20, 70)
	ccR.GUI.Create.Class_Button("Char_Features", "Features", 8, -55, 20, 70)
	ccR.GUI.Create.Class_Button("Char_Setup", "Setup", 8, -70, 20, 70)

	ccR.GUI.Create.Class_Button("ClassFeatures", "Class\nFeatures", 8, -165, 50, 70)
-- 1st Row
	ccR.GUI.Create.Frame_Button("Racials", "Racials", 8, -10)
	ccR.GUI.Create.Frame_Button("Trinkets", "Trinkets", 8, -25)
	ccR.GUI.Create.Frame_Button("Options", "Options", 8, -40)
	ccR.GUI.Create.Frame_Button("Auto", "Auto", 8, -55)
	ccR.GUI.Create.Frame_Button("Tools", "Tools", 8, -70)

	ccR.GUI.Create.Frame_Button("Debug", "Debug", 8, -170)
	ccR.GUI.Create.Frame_Button("Advanced", "Advanced", 8, -185)
	ccR.GUI.Create.Frame_Button("About", "About", 8, -200)
	ccR.GUI.Create.Button("Switch", "Switch", 8, -215, nil, nil, nil, 
	function() 
		for x = 1, # ccR.GUI.Saved.Frame_Buttons do
			if _G[ccR.GUI.Saved.Frame_Buttons[x]]:IsShown() then
				_G[ccR.GUI.Saved.Frame_Buttons[x]]:Hide()
			else
				ccR_GUI_Title:AddMessage("_ccR Addon Settings", 0, 0.75, 0.75, 1)
				_G[ccR.GUI.Saved.Frame_Buttons[x]]:Show()
			end
		end
		for x = 1, # ccR.GUI.Saved.Class_Buttons do
			if _G[ccR.GUI.Saved.Class_Buttons[x]]:IsShown() then
				_G[ccR.GUI.Saved.Class_Buttons[x]]:Hide()
			else
				ccR_GUI_Title:AddMessage("_ccR Class Settings", 0, 0.75, 0.75, 1)
				_G[ccR.GUI.Saved.Class_Buttons[x]]:Show()
			end
		end
	end)
	ccR.GUI.Create.Button("Close", "Close", 8, -230, nil, nil, nil, function() ccR.GUI.Toggle() end)
-- Frames
	-- 1st Row
		-- Racials
			ccR.GUI.Create.Frame("Racials")
			ccR.GUI.Create.Checkbox("chkBloodFury", "Blood Fury", 0, -0, nil, nil, "Racials", "Use_Blood_Fury")
			ccR.GUI.Create.Checkbox("chkBerserking", "Berserking", 0, -15, nil, nil, "Racials", "Use_Berserking")
			ccR.GUI.Create.Checkbox("chkOnBossOnly", "On Boss Only", 100, -7, nil, nil, "Racials", "Use_OnBossOnly")
			ccR.GUI.Create.CheckEditSave("Arcane_Torrent", "Arcane Torrent", 0, -30, nil, nil, "Racials", "Use_Arcane_Torrent", "Arcane_Torrent_Count")	
			ccR.GUI.Create.CheckEditSave("Warstomp", "Warstomp", 0, -45, nil, nil, "Racials", "Use_Warstomp", "Warstomp_Count")
			ccR.GUI.Create.Checkbox("chkQuaking_Palm", "Quaking Palm", 0, -60, nil, nil, "Racials", "Use_Quaking_Palm")
			ccR.GUI.Create.CheckEditSave("Gift_of_the_Naaru", "Gift of the Naaru", 0, -75, nil, nil, "Racials", "Use_Gift_of_the_Naaru", "Gift_of_the_Naaru_Count")
			ccR.GUI.Create.Checkbox("chkStoneform", "Stoneform", 0, -90, nil, nil, "Racials", "Use_Stoneform")
			ccR.GUI.Create.Checkbox("chkEscape_Artist", "Escape Artist", 0, -105, nil, nil, "Racials", "Use_Escape_Artist")
			ccR.GUI.Create.Checkbox("chkEvery_Man_For_Himself", "Every Man For Himself", 0, -120, nil, nil, "Racials", "Use_Every_man_for_Himself")
			ccR.GUI.Create.Checkbox("chkWill_of_the_Forsaken", "Will of the Forsaken", 0, -135, nil, nil, "Racials", "Use_Will_of_the_Forsaken")
		-- Trinkets
			ccR.GUI.Create.Frame("Trinkets")
			ccR.GUI.Create.Checkbox("chkUseTrinket13", "Use Trinket #1", 0, 0, nil, nil, "Trinkets", "Trinket_13", {"chkUseTrinket13_OnlyOnBoss"})
				ccR.GUI.Create.Checkbox("chkUseTrinket13_OnlyOnBoss", "When in dungeon, Only on boss.", 15, -15, nil, nil, "Trinkets", "Trinket_13_OnlyOnBoss")
			ccR.GUI.Create.Checkbox("chkUseTrinket14", "Use Trinket #2", 0, -30, nil, nil, "Trinkets", "Trinket_14", {"chkUseTrinket14_OnlyOnBoss"})
				ccR.GUI.Create.Checkbox("chkUseTrinket14_OnlyOnBoss", "When in dungeon, Only on boss.", 15, -45, nil, nil, "Trinkets", "Trinket_14_OnlyOnBoss")
		-- Options
			ccR.GUI.Create.Frame("Options")
			ccR.GUI.Create.Checkbox("chkUseRotationOnMount", "Use rotations when mounted.", 0, 0, nil, nil, "Options", "Use_Rotation_On_Mount")
			ccR.GUI.Create.Checkbox("chkHideToggle", "Do not show Enabled/Disabled.", 0, -15, nil, nil, "Options", "Hide_Toggle")
		-- Auto
			ccR.GUI.Create.ScrollFrame("Auto", 300)
			ccR.GUI.Create.Checkbox("chkUseAutoFace", "Facing", 0, 0, nil, nil, "Auto", "Use_Auto_Face", {"chkUseAutoFace_InCombatOnly"} )
				ccR.GUI.Create.Checkbox("chkUseAutoFace_InCombatOnly", "Only in combat", 15, -15, nil, nil, "Auto", "Auto_Face_InCombatOnly")
			ccR.GUI.Create.Checkbox("chkUseAutoLoot", "Looting", 0, -30, nil, nil, "Auto", "Use_Auto_Loot", {"chkUseAutoLootARang", "chkUseAutoLootFetch", "chkUseAutoLootInStealth","chkUseAutoLootInDungeons"} )
				ccR.GUI.Create.Checkbox("chkUseAutoLootARang", "Use Loot-a-Rang", 15, -45, nil, nil, "Auto", "Auto_Loot_Use_LootARang")
				ccR.GUI.Create.Checkbox("chkUseAutoLootFetch", "Use Fetch", 140, -45, nil, nil, "Auto", "Auto_Loot_Use_Fetch")
				ccR.GUI.Create.Checkbox("chkUseAutoLootInStealth", "Use In Stealth", 15, -60, nil, nil, "Auto", "Auto_Loot_In_Stealth")
				ccR.GUI.Create.Checkbox("chkUseAutoLootInDungeons", "Use In Dungeons", 15, -75, nil, nil, "Auto", "Auto_Loot_In_Dungeons")
			ccR.GUI.Create.Checkbox("chkUseAutoTarget", "Targeting", 0, -90, nil, nil, "Auto", "Use_Auto_Target", {"chkUseAutoTarget_IgnoreTapped", "chkUseAutoTarget_IgnorePets", "chkUseAutoTarget_InGroup","chkUseAutoTarget_TappedOnly","chkUseAutoTarget_LowestHealth","chkUseAutoTarget_Closest", "chkUseAutoTarget_AlwaysClosest", "chkUseAutoTarget_OnlyVisible","chkUseAutoTarget_OnlyInfront"})
				ccR.GUI.Create.Checkbox("chkUseAutoTarget_IgnoreTapped", "Avoid other player's Tapped", 15, -105, nil, nil, "Auto", "Auto_Target_Ignore_Tapped")
				ccR.GUI.Create.Checkbox("chkUseAutoTarget_IgnorePets", "Ignore Pets", 15, -120, nil, nil, "Auto", "Auto_Target_Ignore_Pets")

				ccR.GUI.Create.Checkbox("chkUseAutoTarget_InGroup", "Any when solo, Tapped in groups.", 15, -135, nil, nil, "Auto", "Auto_Target_In_Group", nil, {"chkUseAutoTarget_TappedOnly"})
				ccR.GUI.Create.Checkbox("chkUseAutoTarget_TappedOnly", "Tapped only", 15, -150, nil, nil, "Auto", "Auto_Target_Tapped_Only", nil, {"chkUseAutoTarget_InGroup"})
				ccR.GUI.Create.Checkbox("chkUseAutoTarget_LowestHealth", "Lowest Health", 15, -165, nil, nil, "Auto", "Auto_Target_Lowest_Health", nil, {"chkUseAutoTarget_Closest", "chkUseAutoTarget_AlwaysClosest"})
				ccR.GUI.Create.Checkbox("chkUseAutoTarget_Closest", "Closest", 15, -180, nil, nil, "Auto", "Auto_Target_Closest", nil, {"chkUseAutoTarget_LowestHealth", "chkUseAutoTarget_AlwaysClosest"})
				ccR.GUI.Create.Checkbox("chkUseAutoTarget_AlwaysClosest", "Always Closest", 140, -180, nil, nil, "Auto", "Auto_Target_AlwaysClosest", nil, {"chkUseAutoTarget_LowestHealth", "chkUseAutoTarget_Closest"})

				ccR.GUI.Create.Checkbox("chkUseAutoTarget_OnlyVisible", "Only Visible", 15, -195, nil, nil, "Auto", "Auto_Target_OnlyVisible")
				ccR.GUI.Create.Checkbox("chkUseAutoTarget_OnlyInfront", "Only Facing", 15, -210, nil, nil, "Auto", "Auto_Target_OnlyInfront")

			ccR.GUI.Create.CheckEditSave("chkHealthPotions", "Health Potions", 0, -225, nil, nil, "Auto", "Use_Health_Potions", "Health_Potion_HP")	
			ccR.GUI.Create.CheckEditSave("chkManaPotions", "Mana Potions", 0, -240, nil, nil, "Auto", "Use_Mana_Potions", "Mana_Potion_MP")	
			ccR.GUI.Create.CheckEditSave("chkAutoJoinLFG", "Accept LFG", 0, -255, nil, nil, "Auto", "Use_Auto_LFG", "Auto_LFG_Time", nil, {"chkAutoJoinLFG_NotInCombat"})	
				ccR.GUI.Create.Checkbox("chkAutoJoinLFG_NotInCombat", "Not while in combat", 15, -270, nil, nil, "Auto", "Auto_LFG_NotInCombat")
			ccR.GUI.Create.CheckEditSave("chkAutoJoinPVP", "Accept PVP", 0, -285, nil, nil, "Auto", "Use_Auto_PVP", "Auto_PVP_Time", nil, {"chkAutoJoinPVP_NotInCombat"})	
				ccR.GUI.Create.Checkbox("chkAutoJoinPVP_NotInCombat", "Not while in combat", 15, -300, nil, nil, "Auto", "Auto_PVP_NotInCombat")
		-- Tools
			ccR.GUI.Create.Frame("Tools")
			ccR.GUI.Create.Button("tMilling", "Milling", 8, 0, nil, 90, "Tools", function() ccR.Tools.Collect("Milling") end)
				ccR.GUI.Create.Button("tMillingStop", "Stop", 93, 0, nil, nil, "Tools", function() ccR_Timer.Unregister('ccR_Milling') _G["ccR_GUI_Frame_Tools_tMillingStop"]:Hide() ccR.PrintToChat("Milling Stopped!") end)
				_G["ccR_GUI_Frame_Tools_tMillingStop"]:Hide()
			ccR.GUI.Create.Button("tProspecting", "Prospecting", 8, -15, nil, 90, "Tools", function() ccR.Tools.Collect("Prospecting") end)
				ccR.GUI.Create.Button("tProspectingStop", "Stop", 93, -15, nil, nil, "Tools", function() ccR_Timer.Unregister('ccR_Prospecting') _G["ccR_GUI_Frame_Tools_tProspectingStop"]:Hide() ccR.PrintToChat("Prospecting Stopped!") end)
				_G["ccR_GUI_Frame_Tools_tProspectingStop"]:Hide()
			ccR.GUI.Create.Button("tDisenchanting", "Disenchanting", 8, -30, nil, 90, "Tools", function() ccR.Tools.Collect("Disenchanting") end)
				ccR.GUI.Create.Button("tDisenchantingStop", "Stop", 93, -30, nil, nil, "Tools", function() ccR_Timer.Unregister('ccR_Disenchanting') _G["ccR_GUI_Frame_Tools_tDisenchantingStop"]:Hide() ccR.PrintToChat("Disenchanting Stopped!") end)
				_G["ccR_GUI_Frame_Tools_tDisenchantingStop"]:Hide()
			--ccR.GUI.Create.MissingFontString("fsMissingToolsGUI", "No Tools available yet.", 0, 0, 250, 200, 16, "Tools")
		-- Debug
			ccR.GUI.Create.ScrollFrame("Debug", 460)
			local width = 155
			local left = 160
			local ebCount = 1
			function _ebTop() ebTop = -20*ebCount ebCount = ebCount + 1 return ebTop end
			local fsCount = 1
			local fontsize = 12
			function _fsTop() fsTop = -20*fsCount fsCount = fsCount + 1 return fsTop end
			ccR.GUI.Create.CheckEditSave("chkDebug", "Enable", 0, 0, nil, nil, "Debug", "UseDebug", "Debug_Delay")	
			ccR.GUI.Create.Checkbox("chkDB_ShowCast", "Show Cast", 0, -15, nil, nil, "Debug", "Debug_ShowCast")

			ccR.GUI.Create.FontString("dbPlayerCount8", "Player.Count(8):", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebPlayerCount8", left, _ebTop(), 18, 80, "Debug")
			ccR.GUI.Create.FontString("dbPlayerCount10", "Player.Count(10):", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebPlayerCount10", left, _ebTop(), 18, 80, "Debug")
			ccR.GUI.Create.FontString("dbPlayerCount12", "Player.Count(12):", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebPlayerCount12", left, _ebTop(), 18, 80, "Debug")
			ccR.GUI.Create.FontString("dbPlayerCount16", "Player.Count(16):", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebPlayerCount16", left, _ebTop(), 18, 80, "Debug")
			ccR.GUI.Create.FontString("dbTargetExists", "Target exists:", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebTargetExists", left, _ebTop(), 18, 80, "Debug")
			ccR.GUI.Create.FontString("dbTargetIsBoss", "Target is Boss:", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebTargetIsBoss", left, _ebTop(), 18, 80, "Debug")
			ccR.GUI.Create.FontString("dbTargetDistanceToCenter", "Target distance (center):", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebTargetDistanceToCenter", left, _ebTop(), 18, 80, "Debug")
			ccR.GUI.Create.FontString("dbTargetDistanceToCombatReach", "Target distance (c reach):", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebTargetDistanceToCombatReach", left, _ebTop(), 18, 80, "Debug")
			ccR.GUI.Create.FontString("dbTargetLoS", "Target is in LoS:", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebTargetLoS", left, _ebTop(), 18, 80, "Debug")
			ccR.GUI.Create.FontString("dbTargetCount8", "Target.Count(8):", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebTargetCount8", left, _ebTop(), 18, 80, "Debug")
			ccR.GUI.Create.FontString("dbTargetCount10", "Target.Count(10):", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebTargetCount10", left, _ebTop(), 18, 80, "Debug")
			ccR.GUI.Create.FontString("dbTargetCount12", "Target.Count(12):", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebTargetCount12", left, _ebTop(), 18, 80, "Debug")
			ccR.GUI.Create.FontString("dbTargetCount16", "Target.Count(16):", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebTargetCount16", left, _ebTop(), 18, 80, "Debug")
			ccR.GUI.Create.FontString("dbEnemies", "# ccR_Enemies:", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebEnemies", left, _ebTop(), 18, 80, "Debug")
			ccR.GUI.Create.FontString("dbEnemiesInCombat", "# ccR_Enemies_In_Combat:", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebEnemiesInCombat", left, _ebTop(), 18, 80, "Debug")
			ccR.GUI.Create.FontString("dbEnemiesWithin44", "# ccR_Enemies_Within_44:", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebEnemiesWithin44", left, _ebTop(), 18, 80, "Debug")
			ccR.GUI.Create.FontString("dbEnemiesWithin16", "# ccR_Enemies_Within_16:", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebEnemiesWithin16", left, _ebTop(), 18, 80, "Debug")
			ccR.GUI.Create.FontString("dbEnemiesWithin12", "# ccR_Enemies_Within_12:", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebEnemiesWithin12", left, _ebTop(), 18, 80, "Debug")
			ccR.GUI.Create.FontString("dbEnemiesWithin10", "# ccR_Enemies_Within_10:", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebEnemiesWithin10", left, _ebTop(), 18, 80, "Debug")
			ccR.GUI.Create.FontString("dbEnemiesWithin8", "# ccR_Enemies_Within_8:", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebEnemiesWithin8", left, _ebTop(), 18, 80, "Debug")



			ccR.GUI.Create.FontString("dbFriendly", "# ccR_Friendly:", 0, _fsTop(), width, 18, fontsize, "Debug", "RIGHT")
			ccR.GUI.Create.Editbox("ebFriendly", left, _ebTop(), 18, 80, "Debug")
			-- _G["ccR_GUI_Frame_Debug_ebFriendly"]:GetText()
		-- Advanced
			ccR.GUI.Create.Frame("Advanced")
			ccR.GUI.Create.CheckEditSave("chkObjectList", "Object List (per ms)", 0, 0, nil, nil, "Advanced", "UseObjectList", "Object_List_Delay", "lock")	
			ccR.GUI.Create.CheckEditSave("chkRotation", "Rotation (per ms)", 0, -15, nil, nil, "Advanced", "UseRotation", "Rotation_Speed", "lock")	
			ccR.GUI.Create.Checkbox("chkAdv_AT", "Auto Target", 0, -30, nil, nil, "Advanced", "Use_Auto_Target")
			ccR.GUI.Create.Checkbox("chkAdv_AT_WTS", "Visible on screen", 10, -45, nil, nil, "Advanced", "WTS_AutoTarget")
			ccR.GUI.Create.Checkbox("chkAdv_AT_LOS", "In line of sight", 10, -60, nil, nil, "Advanced", "LoS_AutoTarget")
			ccR.GUI.Create.CheckEditSave("chkAdv_AT_Delay", "Delay time", 10, -75, nil, nil, "Advanced", "Use_Auto_Target", "Auto_Target_Delay", "lock")	
			ccR.GUI.Create.Checkbox("chkAdv_AF", "Auto Face", 0, -90, nil, nil, "Advanced", "Use_Auto_Face")
			ccR.GUI.Create.Checkbox("chkAdv_AF_CO", "Only in combat", 10, -105, nil, nil, "Advanced", "Auto_Face_InCombatOnly")
			ccR.GUI.Create.CheckEditSave("chkAdv_AF_Delay", "Delay time", 10, -120, nil, nil, "Advanced", "Use_Auto_Face", "Auto_Face_Delay", "lock")	
			ccR.GUI.Create.CheckEditSave("chkClassFeatures", "Class Features (per ms)", 0, -135, nil, nil, "Advanced", "UseClassFeatures", "Player_Features_Delay", "lock")	
		-- About
			ccR.GUI.Create.ScrollFrame("About", 340)
			ccR.GUI.Create.FontString("abTitle", "_ccR Addon!", 5, -5, 140, 22, 16, "About")
			ccR.GUI.Create.FontString("abDescription", 
			"This addon is developed by |cFF00FF00CrazyCactuaR|r at the |cFFF00000FireHack|r forums.\n\nThe addon is FREE to all subscribers of FireHack.\n\nCredits to;\n|cFF00AAFFl0l1dk|r, |cFF00AAFFAnkhy|r, |cFF00AAFFcdMichealB|r, |cFF00AAFFCodeMyLife|r, |cFF00AAFFWopak|r, |cFF00AAFFG1zStar|r, |cFF00AAFFsSateneth|r, |cFF00AAFFDiesal|r, |cFF00AAFFPhelps|r.\n\nAlso a very big thank you to anyone who has donated to help me maintain a wow subscription to continue developing and improving this addon.\n\nBelow are buttons to Donate, Check the change log and to FireHack.\n\n|cFFF00000** Warning **|r\n\nOpenURL() may crash WoW, Until l0l1dk fixes it."
			, 5, -25, 230, 270, 12, "About")
			ccR.GUI.Create.Button("abDonate", "Donate", 10, -300, nil, nil, "About", function() OpenURL("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=crazycactuar%40gmail%2ecom&lc=US&item_name=_ccR%20Donation&no_note=0&currency_code=GBP&bn=PP-DonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest") end)
			ccR.GUI.Create.Button("abChangeLog", "Changes", 85, -300, nil, nil, "About", function() OpenURL("https://code.google.com/p/ccr-wod/source/list") end)
			ccR.GUI.Create.Button("abFireHack", "FireHack", 165, -300, nil, nil, "About", function() OpenURL("http://www.fh-wow.com/") end)
	-- 2nd Row
		-- Rotation
			ccR.GUI.Create.Frame("Rotation")
			-- Drop Down Box
				if not DDM then CreateFrame("Button", "DDM", _G[GUIParentFrame .. "Rotation"], "UIDropDownMenuTemplate") end
				DDM:SetPoint("TOPLEFT", -15, 0)
				DDM:Show()
				DDM_List = { }
				local function OnClick(self)
					UIDropDownMenu_SetSelectedID(DDM, self:GetID())
					fsDescription:SetText(ccR.GUI.Saved.Rotation[UIDropDownMenu_GetSelectedID(DDM)])
					ccR.GUI.Rotation.Save()
					ccR.GUI.Update() 
				end
				local function initialize(self, level)
				   	local info = UIDropDownMenu_CreateInfo()
				   	for k,v in pairs(DDM_List) do
				    	info = UIDropDownMenu_CreateInfo()
				    	info.text = v
				    	info.value = v
				    	info.name = v
				    	info.func = OnClick
				    	UIDropDownMenu_AddButton(info, level)
					end
				end
				UIDropDownMenu_Initialize(DDM, initialize)
				UIDropDownMenu_SetWidth(DDM, 190);
				UIDropDownMenu_SetButtonWidth(DDM, 190)
				UIDropDownMenu_SetSelectedID(DDM, 1)
				UIDropDownMenu_JustifyText(DDM, "LEFT")
				--ccR.GUI.Create.Button("Scan", "Scan", 145, -30, nil, nil, "Rotation", function() ccR.GUI.Rotation.Scan() end)
			-- Description Title
				ccR.GUI.Create.FontString("fsTitle", "Rotation Description", 5, -33, 140, 22, 16, "Rotation")
			-- Description
				ccR.GUI.Create.FontString("fsDescription", "", 5, -50, 215, 180, 12, "Rotation")
		-- Char_Features
			ccR.GUI.Create.Frame("Char_Features")
			ccR.GUI.Create.MissingFontString("fsMissingFeaturesGUI", "No features GUI available.", 0, 0, 250, 200, 16, "Char_Features")
		-- Char_Talents
			ccR.GUI.Create.Frame("Char_Talents")
			ccR.GUI.Create.MissingFontString("fsMissingTalentsGUI", "No talents GUI available.", 0, 0, 250, 200, 16, "Char_Talents")
		-- Char_Abilities
			ccR.GUI.Create.Frame("Char_Abilities")
			ccR.GUI.Create.MissingFontString("fsMissingAbilitiesGUI", "No abilities GUI available.", 0, 0, 250, 200, 16, "Char_Abilities")
		-- Char_Setup
			ccR.GUI.Create.Frame("Char_Setup")
			ccR.GUI.Create.MissingFontString("fsMissingSetupGUI", "No setup GUI available.", 0, 0, 250, 200, 16, "Char_Setup")
		-- Class Features
			ccR.GUI.Create.Frame("ClassFeatures")
			local class = select(2, UnitClass("player"))
			if class == "DEATHKNIGHT" then
				ccR.GUI.Create.CheckEditSave("Deaths_Advance", "Deaths Advance", 0, 0, nil, nil, "ClassFeatures", "Deaths_Advance", "Deaths_Advance_Time")
			elseif class == "ROGUE" then
				ccR.GUI.Create.Checkbox("chkAutoStealth", "Auto Stealth", 0, 0, nil, nil, "ClassFeatures", "Auto_Stealth", { "chkAutoStealth_Resting" })
				ccR.GUI.Create.Checkbox("chkAutoStealth_Resting", "While resting", 15, -15, nil, nil, "ClassFeatures", "Auto_Stealth_Resting")		
				ccR.GUI.Create.CheckEditSave("chkABOS", "Auto Bust of Speed", 0, -30, nil, nil, "ClassFeatures", "Auto_Burst_of_Speed", "Burst_of_Speed_Energy", nil ,{ "chkABOS_InStealth","chkABOS_OutofStealth" })	
					ccR.GUI.Create.Checkbox("chkABOS_InStealth", "In Stealth", 15, -45, nil, nil, "ClassFeatures", "ABOS_InStealth")
					ccR.GUI.Create.Checkbox("chkABOS_OutofStealth", "Out of Stealth", 15, -60, nil, nil, "ClassFeatures", "ABOS_OutOfStealth")
				ccR.GUI.Create.CheckEditSave("chkAuto_Recuperate", "Auto Recuperate", 0, -75, nil, nil, "ClassFeatures", "Auto_Recuperate", "Recuperate_HP", nil, {"chkAR_InStealth","chkAR_OutofStealth"})	
					ccR.GUI.Create.Checkbox("chkAR_InStealth", "In Combat", 15, -90, nil, nil, "ClassFeatures", "AR_InCombat")
					ccR.GUI.Create.Checkbox("chkAR_OutofStealth", "Out of Combat", 15, -105, nil, nil, "ClassFeatures", "AR_OutOfCombat")
				ccR.GUI.Create.Checkbox("chkAuto_TricksoftheTrade", "Auto Tricks of the Trade", 0, -120, nil, nil, "ClassFeatures", "Auto_TricksoftheTrade")
			elseif class == "MONK" then
				ccR.GUI.Create.Checkbox("chkNimbleBrew", "Nimble Brew", 0, 0, nil, nil, "ClassFeatures", "Nimble_Brew")
			elseif class == "PRIEST" then
				ccR.GUI.Create.CheckEditSave("chkAngelic_Feather", "Angelic Feather", 0, 0, nil, nil, "ClassFeatures", "Angelic_Feather", "Angelic_Feather_Time")	
			elseif class == "HUNTER" then
				ccR.GUI.Create.Checkbox("chkAspect_of_the_Cheetah", "Auto Cheetah", 0, 0, nil, nil, "ClassFeatures", "Aspect_of_the_Cheetah")
			elseif class == "MAGE" then
				ccR.GUI.Create.CheckEditSave("chkSlow_Fall", "Slow Fall", 0, 0, nil, nil, "ClassFeatures", "Slow_Fall", "Slow_Fall_Time")	
			else
				ccR.GUI.Create.MissingFontString("fsMissingClassFeaturesGUI", "No class features are\n available yet.", 0, 0, 250, 200, 16, "ClassFeatures")
			end

--[[	local R, G, B
	local class = select(2, UnitClass("player"))
	if class == "DEATHKNIGHT" then R = 0.77 G = 0.12 B = 0.23 
	elseif class == "DRUID" then R = 1 G = 0.49 B = 0.04
	elseif class == "HUNTER" then R = 0.67 G = 0.83 B = 0.45
	elseif class == "MAGE" then R = 0.41 G = 0.80 B = 0.94
	elseif class == "MONK" then R = 0.33 G = 0.54 B = 0.52
	elseif class == "PALADIN" then R = 0.96 G = 0.55 B = 0.73
	elseif class == "PRIEST" then R = 0.99 G = 0.99 B = 0.99
	elseif class == "ROGUE" then R = 1 G = 0.96 B = 0.41
	elseif class == "SHAMAN" then R = 0 G = 0.44 B = 0.87
	elseif class == "WARLOCK" then R = 0.58 G = 0.51 B = 0.79
	elseif class == "WARRIOR" then R = 0.78 G = 0.61 B = 0.43
	end

	local button = CreateFrame("Button", nil, _G["ccR_GUI"])
	button:SetPoint("CENTER", _G["ccR_GUI"], "CENTER", 0, -25)
	button:SetWidth(70)
	button:SetHeight(20)
	button:SetText(class)
	button:SetNormalFontObject("GameFontNormal")

	local btnBorder = button:CreateTexture()
	btnBorder:SetTexture(R, G, B, 1)
	btnBorder:SetVertexColor(R, G, B, 1)
	btnBorder:SetAllPoints()

	local ntex = button:CreateTexture()
	ntex:SetTexture(0.0, 0.0, 0.0, 1)
	ntex:SetWidth(65)
	ntex:SetHeight(15)
	ntex:SetPoint("CENTER", button, "CENTER", 0, 0)
	ntex:SetBlendMode("DISABLE")
	button:SetNormalTexture(ntex)
	
	local htex = button:CreateTexture()
	htex:SetTexture(R, G, B, 1)
	htex:SetVertexColor(R, G, B, 1)
	htex:SetWidth(65)
	htex:SetHeight(15)
	htex:SetPoint("CENTER", button, "CENTER", 0, 0)
	button:SetHighlightTexture(htex)
	
	local ptex = button:CreateTexture()
	ptex:SetTexture(R, G, B, 1)
	ptex:SetVertexColor(R, G, B, 1)
	ptex:SetWidth(65)
	ptex:SetHeight(15)
	ptex:SetPoint("CENTER", button, "CENTER", 0, 0)
	button:SetPushedTexture(ptex)
]]

ccR.GUI.Update()
ccR_GUI:Hide()
